<?php
session_start();
      if (isset($_SESSION['k_username'])) {
		include('conexion.inc.php');
  $link=Conectarse();
  mysql_select_db("gotica_ordencompras" ,$link);  
echo "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />";
echo "<title >Productos</title>";
?>
<style type="text/css">
<!--BODY {
	background-color: #EBEBEB;
	margin-left: 20px;
	margin-top: 20px;
	margin-right: 0px;
	margin-bottom: 0px;
	font-size: 90%;
}
TD{
	font-family: Verdana, Helvetica, sans-serif;
 	font-size: 12px
}
H1 {
	font : bold 14pt  Verdana, Tahoma, sans-serif;
	text-align : left;
	margin-bottom : 0;
	margin-left : 0;
	margin-right : 0;
	margin-top : 0;
}
H1.mess {
	font : bold 14pt Verdana, Tahoma, sans-serif;
	text-align : center;
	color : red;
	margin-bottom : 0;
	margin-left : 0;
	margin-right : 0;
	margin-top : 0;
}
TR.data{
	background : #A6A6A6;
	font-family: Verdana, Helvetica, sans-serif;
 	font-size: 12px
}
TR.dataheader{
	font-family: Verdana, Helvetica, sans-serif;
	background : #808080;
	font-weight : bold;
	text-align : center;
	font-size: 12px
}
H2{
	font : bold 13px Verdana, Tahoma, sans-serif;
	text-align : center;
	margin-bottom : 0;
	margin-left : 0;
	margin-right : 0;
	margin-top : 0;
}
P {
	margin : 3;
}
A {
	font: Verdana, Tahoma, sans-serif;
	color : blue;
	font-size: 16px;
}
A:HOVER {
	font: Verdana, Tahoma, sans-serif;
	color : red;
	text-decoration : underline;
}
/*A:LINK {
text-decoration : none;
}
*/
A:VISITED {
	font: Verdana, Tahoma, sans-serif;
	text-decoration : none;
}
A.menu {
	font: bold 12px Verdana, Tahoma, sans-serif;
	color : #B75E0B;
	text-decoration : none;
}
A.menu:HOVER {
	font: Verdana, Tahoma, sans-serif;
	color : Navy;
}
A.menuACT {
	font: bold 12px Verdana, Tahoma, sans-serif;
	color : red;
	text-decoration : none;
}
/* FORM CLASSES */
.INPUTmy {
	border : 1px solid #000080;
	background : White;
	font-family : Courier New;
	font-size : 12px;
}
.INPUTmyERR {
	border : 1px solid Black;
	font-family : Courier New;
	font-size : 12px;
	background : #CC6633;
}
.INPUTmyACT {
	border : 1px solid #990033;
	background : #FFFFCC;
	font-family : Courier New;
	font-size : 12px;
	color : #000099;
}
.BUTTONmi {
	font-family: Verdana, Tahoma, sans-serif;
	font-size: 12px;
	color: black ;
	background-color: #EBEBEB;
	border: 1px solid Black;
	width : 70px;
}
.BUTTONmySmall {
	font-family: Verdana, Tahoma, sans-serif;
	font-size: 12px;
	color: black ;
	background-color: #CCCCCC;
	border: 1px solid Black;
}
.ERROR_HEADER{
	color: red;
	font : bold;
	text-align : center;
}
.ERROR_ELEMENT{
	color: red ;
}
/* END FORM CLASSES*/
.header {
	color : Teal;
	text-align : center;
	font : bold 13px;
}
-->
</style>



<?
echo "<style type=\"text/css\">";
echo "<!--
.Estilo1 {font-size: 24px}
-->
</style>";

?>
</head>
<body>
<div align="center" ><h1>Productos<h1></div>
<form method="post" action="buscaprod.php">
<input type="text" name="busqueda" value="Buscar..." onFocus="javascript:this.value='';" onBlur="javascript:document.search_form.reset();" />
<input type="hidden" name="tipoprod" value="15" />
<input type="image" src="../imagenes/viewmag.png" style="border:0px;margin-left:10px;margin-right:3px;" align="absmiddle" value="Buscar" name="busca" />
</form>
<br />
<form method="post" action="buscaprod.php">
<table>
<tr>
<?php 
$sqlt = "SELECT * FROM tipoproducto";
$resultt = mysql_query($sqlt, $link);
echo "<td><select name=\"tipoprod\" />";

while ($rowt = mysql_fetch_array($resultt))
{
	$de=$rowt['idtipoprod'];
echo "<option value=\"".$de."\">";
echo utf8_encode($rowt['tipoprod']);
echo "</option>";
}
echo "</select></td>";
?>
<td>
<input type="submit" value="Elegir Tipo" name="buscatipo" />
</td>
</tr>
</table>

</form>


<table width="100%" border="0" cellspacing="2" cellpadding="2" align="center" >
<tr align="center" class="dataheader">
<td>Editar</td>
<td>Borrar</td>
<td>Codigo</td>
<td>Nombre</td>
<td>Descripcion</td>
<td>Proveedor</td>
<td>Precio en Proveedor</td>
</tr>
<?
$sql2= "SELECT * FROM producto ORDER BY idtipoprod ASC, codigo ASC";
$result2 = mysql_query($sql2, $link);

while ($row2= mysql_fetch_array($result2)){

echo "<tr class=\"data\">";
echo "<form method=\"post\" action=\"edicionprod.php\">";
echo "<td width=\"3%\"><input type=\"hidden\" name=\"idproducto\" value=\"$row2[idproducto]\" /><input type=\"submit\" class=\"buttonmi\" name=\"ver\" value=\"Editar\" /></td>";
echo "</form>";
echo "<form method=\"post\" action=\"borraprod.php\">";
echo "<td width=\"3%\"><input type=\"hidden\" name=\"idproducto\" value=\"$row[idproducto]\" /><input type=\"submit\" class=\"buttonmi\" name=\"ver\" value=\"Borrar\" /></td>";
echo "</form>";
$sql5 = "SELECT * FROM tipoproducto WHERE idtipoprod=". $row2['idtipoprod'];
$result5 = mysql_query($sql5, $link);
$row5 = mysql_fetch_array($result5);
$codigo=$row5['siglatprod']."-".$row2['codigo'];
echo "<td>";
echo $codigo;
echo "</td>";
echo "<td>";
echo $row2['n_producto'];
echo "</td>";
echo "<td>";
echo $row2['T_descripcion'];
echo "</td>";
$sql3 = "SELECT * FROM prod_provdo WHERE idproducto=".$row2['idproducto'];
$result3 = mysql_query($sql3, $link);
$row3 = mysql_fetch_array($result3);
$sql4 = "SELECT * FROM proveedor WHERE idproveedor=". $row3['idproveedor'];
$result4 = mysql_query($sql4, $link);
$row4 = mysql_fetch_array($result4);
echo "<td>";
echo $row4['N_proveedor'];
echo "</td>";
echo "<td>";
echo $row3['preciounitario'];
echo "</td>";
echo "</tr>";

	
	}


?>
</table>
</body>
</html>
<?
}else
{
	echo "<SCRIPT LANGUAGE=\"javascript\">";
echo "location.href = \"index.php\"";
echo "</SCRIPT>";
	}
?>
